<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>判断是否是闰年</title>
</head>

<body>
    <script type="text/javascript">
        var n = parseInt(prompt("请输入年份"));
        if (isNaN(n)) {
            alert('请输入正确的年份');
        } else {
            alert(year(n));
        }

        function year(n) {
            if (n % 4 == 0 && n % 100 != 0 || n % 400 == 0) {
                return "输入的年份为闰年";
            } else {
                return "输入的年份为平年";
            }
        }
    </script>
</body>

</html>